package com.zbkj.admin.controller.brand;

import com.zbkj.common.annotation.LogControllerAnnotation;
import com.zbkj.common.enums.MethodType;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.*;
import com.zbkj.common.response.CardBrandForApplyResponse;
import com.zbkj.common.response.PaidMemberCardResponse;
import com.zbkj.common.response.ProductActivityResponse;
import com.zbkj.common.result.CommonResult;
import com.zbkj.common.vo.PaidMemberBenefitsVo;
import com.zbkj.common.vo.PaidMemberConfigVo;
import com.zbkj.service.service.PaidMemberCardApplyService;
import com.zbkj.service.service.PaidMemberCardService;
import com.zbkj.service.service.PaidMemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * 付费会员控制器
 *
 * @author Han
 * @version 1.0.0
 * @Date 2024/5/10
 */
@Slf4j
@RestController
@RequestMapping("api/admin/brand/paid/apply")
@Api(tags = "跨平台会员控制器")
public class BrandPaidMemberApplyController {

    @Autowired
    private PaidMemberCardApplyService paidMemberCardApplyService;

    @PreAuthorize("hasAuthority('brand:paid:member:card:list')")
    @ApiOperation(value="获取能被申请会员卡品牌列表")
    @RequestMapping(value = "/getCardList/{cardId}", method = RequestMethod.GET)
    public CommonResult<List<CardBrandForApplyResponse>> getCardList(@PathVariable(name = "cardId") Integer cardId) {
        return CommonResult.success(paidMemberCardApplyService.getForCardBrands(cardId));
    }
    @PreAuthorize("hasAuthority('brand:paid:member:card:list')")
    @ApiOperation(value="获取该会员申请跨品牌列表")
    @RequestMapping(value = "/getApplyCardBrands/{cardId}", method = RequestMethod.GET)
    public CommonResult<List<CardBrandForApplyResponse>> getApplyCardBrands(@PathVariable(name = "cardId") Integer cardId) {
        return CommonResult.success(paidMemberCardApplyService.getApplyCardBrands(cardId));
    }
    @PreAuthorize("hasAuthority('brand:paid:member:card:list')")
    @ApiOperation(value="会员卡申请跨品牌")
    @RequestMapping(value = "/apply", method = RequestMethod.POST)
    public CommonResult<Boolean> apply(@RequestBody List<PaidMemberCardApplyRequest> request) {
        return CommonResult.success(paidMemberCardApplyService.apply(request));
    }
    @PreAuthorize("hasAuthority('brand:paid:member:card:list')")
    @ApiOperation(value="会员卡审核跨品牌")
    @RequestMapping(value = "/review", method = RequestMethod.POST)
    public CommonResult<Boolean> review(@RequestBody List<PaidMemberCardApplyRequest> request) {
        return CommonResult.success(paidMemberCardApplyService.review(request));
    }

    @PreAuthorize("hasAuthority('brand:paid:member:card:list')")
    @ApiOperation(value = "折扣商品")
    @RequestMapping(value = "/discount", method = RequestMethod.GET)
    public CommonResult<CommonPage<ProductActivityResponse>> getActivitySearchPage(@Validated PageParamRequest pageRequest) {
        return CommonResult.success(CommonPage.restPage(paidMemberCardApplyService.discount( pageRequest)));
    }

}
